<template>
  <div class="product-add">
    <!--form表单-->
    <el-form size="small" ref="form" :model="form" label-width="260px">
      <!--添加门店-->
      <div class="common-form">修改电子面单配置</div>
      <el-form-item label="电子面单配置名称 " prop="settingName" :rules="[{required: true,message: ' '}]">
        <el-input v-model="form.settingName" class="max-w460"></el-input>
      </el-form-item>
      <el-form-item label="快递公司">
        <el-select size="small" v-model="form.expressId" placeholder="请选择" style="width: 460px;">
          <el-option v-for="(item, index) in expressList" :key="index" :label="item.expressName" :value="item.expressId"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="电子面单月结账号(partnerId)" prop="partnerId" :rules="[{required: true,message: ' '}]">
        <el-input v-model="form.partnerId"  class="max-w460"></el-input>
        <div class="tips">电子面单客户编码或月结账号，使用电子面单下单时必填，需贵司向当地快递公司网点申请，其余字段请对照快递100参数字典根据快递公司类型填写
          <el-link :underline="false" href="https://api.kuaidi100.com/document/5f0ff6e82977d50a94e10237.html" target="_blank" type="primary">快递100参数字典</el-link>
        </div>
        <div class="tips"></div>
      </el-form-item>
      <el-form-item label="电子面单密码(partnerKey)">
        <el-input v-model="form.partnerKey"  class="max-w460"></el-input>
      </el-form-item>
      <el-form-item label="电子面单密钥(partnerSecret)">
        <el-input v-model="form.partnerSecret"  class="max-w460"></el-input>
      </el-form-item>
      <el-form-item label="电子面单客户账户名称(partnerName)">
        <el-input v-model="form.partnerName"  class="max-w460"></el-input>
      </el-form-item>
      <el-form-item label="收件网点名称(net)">
        <el-input v-model="form.net"  class="max-w460"></el-input>
      </el-form-item>
      <el-form-item label="电子面单承载编号(code)">
        <el-input v-model="form.code"  class="max-w460"></el-input>
      </el-form-item>
      <el-form-item label="电子面单承载快递员名(checkMan)">
        <el-input v-model="form.checkMan"  class="max-w460"></el-input>
      </el-form-item>
      <el-form-item label="排序">
        <el-input v-model="form.sort" type="number" class="max-w460"></el-input>
        <div class="tips">数字越小越靠前</div>
      </el-form-item>
      <el-form-item label="排序">
        <el-input v-model="form.sort" type="number" class="max-w460"></el-input>
        <div class="tips">数字越小越靠前</div>
      </el-form-item>
      <!--提交-->
      <div class="common-button-wrapper"><el-button type="primary" @click="onSubmit" :loading="loading" icon="CircleCheck">提交</el-button></div>
    </el-form>
  </div>
</template>

<script>
import SettingApi from '@/api/setting.js';

export default {
  data() {
    return {
      /*切换菜单*/
      // activeIndex: '1',
      /*form表单数据*/
      form: {
        labelSettingId: '',
        wxCode: '',
        sort: ''
      },
      /*快递公司列表*/
      expressList: [],
      loading: false
    };
  },
  created() {
    this.getData();
  },

  methods: {
    /*获取数据*/
    getData() {
      let self = this;
      // 取到路由带过来的参数
      const params = this.$route.query.labelSettingId;
      SettingApi.labelDetail(
        {
          labelSettingId: params
        },
        true
      )
        .then(res => {
          let detail = res.data.labelSetting;
          // 将数据放在当前组件的数据内
          self.form = detail;
          self.expressList = res.data.expressList;
        })
        .catch(error => {});
    },

    /*提交表单*/
    onSubmit() {
      let self = this;
      self.loading = true;
      let params = this.form;
      SettingApi.editlabel(params, true)
        .then(data => {
          self.loading = false;
          ElMessage({
            message: '恭喜你，修改成功',
            type: 'success'
          });
          self.$router.push('/setting/label/index');
        })
        .catch(error => {
          self.loading = false;
        });
    },

  }
};
</script>

<style>
.tips {
  color: #ccc;
}
</style>
